package com.llx.use.thread;

import com.llx.use.Logger;

/**
 * @author : Linxu
 * @create : 2021/9/16
 * @update : 2023/2/20
 *            ^__^
 *            (**)\ _ __ _
 *            (__)\       )\/\
 *             U  ||------|
 *                ||     ||
 * ==============================
 * @desc   : 可停止当前Thread的Runnable
 */
public abstract class Run implements Runnable {

    private Thread mThread;

    public boolean interrupted() {
        return mThread == null || mThread.isInterrupted();
    }

    public void stop() {
        stop = true;
        if (mThread != null && !mThread.isInterrupted()) {
            mThread.interrupt();
        }
    }

    @Override
    public void run() {
        mThread = Thread.currentThread();
    }

    public boolean stop;
    public int loop;

    public boolean loop() {
        return false;
    }
}
